var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = cc._decorator,
    s = r.ccclass,
    l = r.property,
    c = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.map_node = null),
                (t.left_mian_tower = null),
                (t.right_mian_tower = null),
                (t._width = 0),
                (t._height = 0),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.initView = function () {
                (this._width = this.map_node.width / 2), (this._height = this.map_node.height / 2);
            }),
            (t.prototype.addEvent = function () {
                this.attachEvent(a.default.SEND_PLAYER_POS_INFO, this.updateGameCamera, this),
                    this.attachEvent(a.default.SEND_GAME_OVER_INFO, this.showGameOver, this);
            }),
            (t.prototype.showGameOver = function () {
                var e = i.GlobalParams.MatchMyIndex % 2 == 0 ? this.left_mian_tower : this.right_mian_tower,
                    t = i.GlobalParams.MatchMyIndex % 2 == 0 ? this.right_mian_tower : this.left_mian_tower;
                this.updateGameCamera("", i.GlobalParams.GamePlayerWin ? t : e);
            }),
            (t.prototype.updateGameCamera = function (e, t) {
                var o = t,
                    n = o.x,
                    a = o.y + 150,
                    r = this._width - cc.winSize.width / 2,
                    s = this._height - cc.winSize.height / 2;
                n < -r ? (n = -r) : n > r && (n = r),
                    a < -s ? (a = -s) : a > s && (a = s),
                    cc
                        .tween(this.node)
                        .to(i.GlobalParams.GameUpdateTime, {position: cc.v3(n, a, 0)})
                        .start();
            }),
            __decorate([l(cc.Node)], t.prototype, "map_node", void 0),
            __decorate([l(cc.Node)], t.prototype, "left_mian_tower", void 0),
            __decorate([l(cc.Node)], t.prototype, "right_mian_tower", void 0),
            __decorate([s], t)
        );
    })(n.default);
o.default = c;
